<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('列表')" />
</head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								渠道名称：<input type="text" name="channelName"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	       <div class="btn-group-sm" id="toolbar" role="group">
<!--				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="channel:wallet:add">-->
<!--					<i class="fa fa-plus"></i> 添加-->
<!--				</a>-->
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="channel:wallet:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('channel:wallet:edit')}]];
        var removeFlag = [[${@permission.hasPermi('channel:wallet:remove')}]];
        var prefix = ctx + "channel/wallet";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "渠道钱包",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '主键id',
					visible: false
				},
				{
					field : 'channelId', 
					title : '渠道标识',
					sortable: true,
                    visible: false
				},
                {
                    field : 'channelName',
                    title : '渠道名称'
                },
				{
					field : 'accountBalance', 
					title : '总金额(元)',
					sortable: true,
                    formatter: function (value, row, index) {
                        if (value != null) {
                            var data = new Decimal(value).div(new Decimal(100.00)).toFixed(2);
                            return data;
                        }
                    }
				},
				{
					field : 'waitLiquidatedBalance',
					title : '待结算金额(元)',
					sortable: true,
                    formatter: function (value, row, index) {
                        if (value != null) {
                            var data = new Decimal(value).div(new Decimal(100.00)).toFixed(2);
                            return data;
                        }
                    }
				},
                 {
                     field : 'latestCheckTime',
                     title : '查询时间'
                 },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="balanceCheck(\'' + row.channelId + '\')"><i class="fa fa-search"></i>查询余额</a> ');
                        //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });


        /* 余额校正 */
		function balanceCheck(channelId) {
            $.modal.loading("正在处理中，请稍后...");
            $.modal.disable();
            $.post( prefix + "/balanceCheck", {'channelId':channelId},function (response) {
                if (response.code == 0) {
                    $.modal.alertSuccess(JSON.stringify(response.data));
                    $.modal.closeLoading();
                    $.table.refresh();
				}else {
                    $.modal.alertError(response.msg);
                    $.modal.closeLoading();
				}
			});
        }
	</script>
</body>
</html>